<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link th:href="@{/erp/assets/css/bootstrap.min.css}" rel="stylesheet" />
    <link rel="stylesheet" th:href="@{/erp/css/style.css}"/>
    <link th:href="@{/erp/assets/css/codemirror.css}" rel="stylesheet">
    <link rel="stylesheet" th:href="@{/erp/assets/css/ace.min.css}" />
    <link rel="stylesheet" th:href="@{/erp/assets/css/font-awesome.min.css}" />
    <link rel="stylesheet" href="/plugins/layui/css/layui.css" media="all">
    <script th:src="@{/plugins/layui/layui.js}"></script>
</head>
<body>
<!--添加产线图层-->
<div class="add_menber" id="add_menber_style">
    <form  class="layui-form">
        <ul class=" page-content">
            <div class="prompt r_f"></div>
            <li><label class="label_name" >产线名称：</label><span class="add_name"><select lay-verify="required" lay-reqtext="请选择产线名称" name="productionName"><option value="">请选择</option><option th:each="x:${list}" th:value="${x.deptName}" th:text="${x.deptName}"></option></select></span><div class="prompt r_f"></div></li>
            <li><label class="label_name" >生产能力：</label><span class="add_name"><input value="" name="productionCapacity" lay-verify="required|number"  lay-reqtext="生产能力不能为空" type="text"  class="text_add"/>&nbsp;组/天</span><div class="prompt r_f"></div></li>
            <li style="position: relative;left: -5px;"><label class="label_name" style="width: 85px;">可生产型号：</label><span class="add_name"><input value="" required  name="model" lay-verify="required|clength" id="clength"  lay-reqtext="可生产型号不能为空" type="text"  class="text_add"/></span><div class="prompt r_f"></div></li>
            <li><label class="label_name" >负责人：</label><span class="add_name"><select lay-verify="required" lay-reqtext="请选择负责人" name="principal" ><option value="">请选择</option><option th:each="s:${list}" th:value="${s.deptManger}" th:text="${s.deptManger}"></option></select></span><div class="prompt r_f"></div></li>
            <li><label class="label_name">产线人数：</label><span class="add_name"><input value="" name="number" lay-verify="required|number"  lay-reqtext="产线人数不能为空" type="text"  class="text_add"/></span><div class="prompt r_f"></div></li>
            <li><label class="label_name">状&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;态：</label><span class="add_name">
                 <label><input name="state" type="radio" value="1" class="ace"><span class="lbl">正在生产</span></label>&nbsp;&nbsp;&nbsp;
                 <label><input name="state" type="radio" value="0" checked="checked" class="ace"><span class="lbl">未生产</span></label></span><div class="prompt r_f"></div></li>
            <li class="adderss"><label class="label_name" style="width:84px">备&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;注：</label><span class="add_name"><input name="remarks" required data="备注" type="textarea"  class="text_add" style=" width:350px"/></span><div class="prompt r_f"></div></li>
            <li class="adderss"><label class="label_name" style="width:260px">&nbsp;&nbsp;&nbsp;&nbsp;</label><button lay-submit lay-filter="formDemo"  class="btn btn-primary radius">确定</button>&nbsp;&nbsp;&nbsp;&nbsp;<input value="重置" name="" type="reset"  class="layui-btn layui-btn-primary"/></li>
        </ul>
    </form>
    <script>
        layui.use('form', function() {
            var form = layui.form;
            var $ = layui.jquery;
            form.verify({
                clength:function (value) {
                    if (value.length > 7){
                        return '请输入正确的生产型号';
                    }
                },
                number:function (value) {
                    if (value.length > 5){
                        return '请输入正确的数量';
                    }
                },
                pname:[/^[\u4e00-\u9fa5]{2,4}$/,'请输入正确的负责人名称'],
            })
            form.on('submit(formDemo)', function(data){
                $.ajax({
                    url:"/production/sc_add",
                    data:data.field,
                    dataType:'json',
                    type:'post',
                    async: false,
                    success:function(mydata){
                        if (mydata == 1) {
                            parent.layui.table.reload("demo");
                            parent.layer.msg('添加成功', {icon: 1});
                            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                            parent.layer.close(index); //再执行关闭
                        }
                    }
                });
            })
        })
    </script>
</div>
</body>
</html>